<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<h1>0</h1>
<div></div>
<script>

    /*setTimeout()获取时间*/
    setTimeout(1000);
    let count = 10
    //开启执行一次的计时器
    let h1=document.querySelector("h1")
    let timer=setInterval(f,1000);
    function f() {
        count--;
        h1.innerText = count;
        if (count==0){
            //停止计时器
            clearInterval(timer);
        }
    }
</script>
</body>
</html>